<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<link rel="stylesheet" href="css/pintuer.css">
<link rel="stylesheet" href="css/admin.css">
<script src="laydate/laydate.js"></script>
<script src="js/jquery-3.5.0.js"></script>
<script type="text/javascript" src="js/jquery.min.js"></script>
<link rel="stylesheet"
	href="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://cdn.staticfile.org/jquery/2.1.1/jquery.min.js"></script>
<script
	src="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script src="js/template-web.js"></script>
<script>
	/* JqueryAjax */
	/* Jquery入口$ */
	
	/**
	 * 时间戳格式化方法
	 * @param date
	 * @param format
	 * @returns {void | string}
	 */
	function dateFormat(date, format) {
	    date = new Date(date);
	    var map = {
	        "M": date.getMonth() + 1, //月份
	        "d": date.getDate(), //日
	        "h": date.getHours(), //小时
	        "m": date.getMinutes(), //分
	        "s": date.getSeconds(), //秒
	        "q": Math.floor((date.getMonth() + 3) / 3), //季度
	        "S": date.getMilliseconds() //毫秒
	    };
	    format = format.replace(/([yMdhmsqS])+/g, function (all, t) {
	        var v = map[t];
	        if (v !== undefined) {
	            if (all.length > 1) {
	                v = '0' + v;
	                v = v.substr(v.length - 2);
	            }
	            return v;
	        } else if (t === 'y') {
	            return (date.getFullYear() + '').substr(4 - all.length);
	        }
	        return all;
	    });
	    return format;
	};
</script>
<script id="orderTpl" type="text/html">
{{each books as book}}
<tr>
<td>{{$index+1}}</td>
<td>{{book.bookname}}</td>
<td>{{book.author}}</td>
<td>{{book.price}}</td>
<td>{{book.borntime| dateFormat:'yyyy-MM-dd h:mm:ss'}}</td>
<td>{{book.image}}</td>
<td>{{book.stock}}</td>
<td>{{book.press}}</td>
<td>{{book.describtion}}</td>
<td>{{if book.status==1}}上架
{{else if book.status==2}}下架
{{/if}}</td>
<td><div class="button-group">
<a class="button border-main view-order" href="javascript:void(0)" data-mydata="{{book.id}}"><span class="icon-edit"></span>修改</a>
</div><div class="button-group">
<a class="button border-main view-order" href="javascript:void(0)" data-mydata="{{book.id}}"><span class="icon-edit"></span>删除</a>
</div></td>
</tr>
{{/each}}
</script>
</head>
<body>
<table class="table table-bordered table-hover table-condensed">
</table>
	<div class="panel admin-panel">
		<table class="table table-hover text-center">
			<thead>
				<tr>
					<th>序号</th>
					<th>书名</th>
					<th>作者</th>
					<th>价格</th>
					<th>出版日期</th>
					<th>图片</th>
					<th>库存</th>
					<th>出版社</th>
					<th>描述</th>
					<th>状态</th>
					<th>操作</th>
				</tr>
			</thead>
			<tbody id="selectAll">

			</tbody>
		</table>
	</div>
	<script type="text/javascript">
function selectAll(){
	$.ajax({
		url:"book/selectAll",
		type:"get",
		dataType : "json",
		success:function(result){
			console.log(result);
			let bookHTML = template("orderTpl", {
				books : result
			});
			$("#selectAll").html(bookHTML);
		}
	});
}
$(function() {
	selectAll();
});
</script>
</body>
</html>
